﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using Aliphant.UI.Widgets;
using Aliphant.UI;
using Aliphant.Interfaces;
using Aliphant.IoC;
using System.Dynamic;
using Aliphant.Script;

namespace ScriptDemo.Views
{
    /// <summary>
    /// WidgetByScript.xaml 的交互逻辑
    /// </summary>
    public partial class WidgetByScript : BaseWidget, IWidget
    {
        public event Action? OnQuickAction1Event;
        public event Action? OnQuickAction2Event;
        public event Action? OnClose;

        public string? quickButton1Tip { get; set; }
        public string? quickButton2Tip { get; set; }
        public string? qucikButton1Icon { get; set; }
        public string? qucikButton2Icon { get; set; }


        public WidgetByScript()
        {
            InitializeComponent();
        }

        public async void SetScriptPath(string scriptPath)
        {
            var manager = IoCServer.Container.Resolve<IScriptManager>();
            await manager.ExecuteAsync(scriptPath, this, new string[] { "Aliphant.UI.Forms" });
        }

        public void Init(Widget widget)
        {

        }

        public void QuickAction1()
        {
            OnQuickAction1Event?.Invoke();
        }

        public void QuickAction2()
        {
            OnQuickAction2Event?.Invoke();
        }

        public void Close()
        {
            OnClose?.Invoke();
        }



        public string? QuickButton1Tip => quickButton1Tip;

        public string? QuickButton2Tip => quickButton2Tip;

        public string? QucikButton1Icon => qucikButton1Icon;

        public string? QucikButton2Icon => qucikButton2Icon;


    }
}
